import requests

from common.conf import url


class LoginAPI():

    def login(self, mdata={"username": "19515542478", "password": "123456"}):
        nurl=url.__add__("/login")
        # 登录

        # my = {"username": "19515542478", "password": "123456"}
        a = requests.post(nurl, data=mdata)
        print(a.json())
        # 提取token
        rdata: dict = a.json()
        # rdata = a.json()
        # t = rdata["Admin-Token"]
        t= rdata.get("Admin-Token")
        token = {"Admin-Token": t}
        return token, rdata.get("code")

if __name__ == '__main__':
    a=LoginAPI().login()
    print(a)